Repository navigation
Add GET agent code-snippets for TypeScript SDK samples - #475
Merged
Merged
Conversation
bhaveshpatel640
requested review from
chiragjn,
debajyoti-truefoundry,
heerambavi1998,
sr07asthana and
thesujai
as code owners
August 27, 2026 14:08
🦋 Changeset detectedLatest commit: 411a79c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
bhaveshpatel640
force-pushed
the
AGE-1996
branch
from
August 27, 2026 14:51
9645e2d to
8e8dcba
Compare
bhaveshpatel640
marked this pull request as draft
August 27, 2026 14:54
bhaveshpatel640
force-pushed
the
AGE-1996
branch
from
August 27, 2026 14:59
8dd4706 to
2552ad0
Compare
bhaveshpatel640
marked this pull request as ready for review
August 27, 2026 14:59
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 411a79c. Configure here.
chiragjn
reviewed
Aug 27, 2026
Member
There was a problem hiding this comment.
minor: We should still add .openapi() annotations even if we are excluding them from docs and sdk - just for consistency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds a harness “Use in Code” API so the UI can fetch TypeScript SDK samples for a named agent (stream and non-stream).
AGE-1996
Changes
GET /api/v1/agents/{agent_id}/code-snippetsx-fern-ignore/x-excluded— not a public SDK method; UI shouldfetchthis JSON (same idea as logout, not a browser redirect){ data: { base_url, snippets[] } }with TypeScriptsample_code.stream/sample_code.non_stream@truefoundry/trueforge-sdk:createTurnStream(events) vscreateTurn+getTurn(no poll loop)@truefoundry/trueforgeHow was this tested?
pnpm --filter @truefoundry/trueforge test -- tests/unit/apis/agents.test.ts(200 with a non-emptysnippetsarray; 404 for unknown id)GET http://localhost:3000/api/v1/agents/<agent_id>/code-snippetsand ran the stream sample withnpx tsx(needs"type": "module"in the scratchpackage.json)Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changedNote
Low Risk
Read-only, UI-oriented endpoint with no changes to auth, sessions, or agent mutation; main risk is stale or misleading sample text if SDK APIs change.
Overview
Adds
GET /api/v1/agents/{agent_id}/code-snippetsso the harness “Use in Code” flow can load ready-to-copy TypeScript samples for a registry agent. The route is documented in OpenAPI but markedx-fern-ignore/x-excluded(UIfetchonly, not a generated SDK method).On success it returns
{ data: { base_url, snippets[] } }, wherebase_urlis the request origin for SDKbaseUrland each snippet includessample_code.streamandsample_code.non_stream. Snippets are built from templates that substitute the agent’s name andbaseUrlvia JSON-safe placeholder rendering (buildAgentCodeSnippets). Samples walk through@truefoundry/trueforge-sdk: create session by agent name, then eithercreateTurnStream(with delta merging) orcreateTurnplusgetTurn. Unknownagent_idreturns 404, matching other agent routes.Unit tests cover 404 for missing ids and a non-empty
snippetsarray for a created agent; a patch changeset records the@truefoundry/trueforgerelease note.Reviewed by Cursor Bugbot for commit 411a79c. Bugbot is set up for automated code reviews on this repo. Configure here.